package io.gitee.hefrankeleyn.hhconfig.demo;

import io.gitee.hefrankeleyn.hhconfig.client.annnotation.EnableHhConfigAnnotation;
import io.gitee.hefrankeleyn.hhconfig.demo.conf.HhDemoConf;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;

@SpringBootApplication
@EnableConfigurationProperties(value = {HhDemoConf.class})
@EnableHhConfigAnnotation
public class HhconfigDemoApplication {

	@Value("${hh.a}")
	private String a;

	@Resource
	private HhDemoConf hhDemoConf;

	@Resource
	private Environment environment;

	public static void main(String[] args) {
		SpringApplication.run(HhconfigDemoApplication.class, args);
	}

	@Bean
	public ApplicationRunner runDemoTest() {
		return (p)->{
			System.out.println(a);
			System.out.println(hhDemoConf.getB());
			System.out.println(environment.getProperty("hh.c"));

		};
	}

}
